package com.lll.demo.service;
//专门管理业务逻辑

import com.lll.demo.entity.User;
import com.lll.demo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public Map<String,Object> userRegist(User user){
        User userOld = userMapper.getMajorOrClassname(user.getMajor(),user.getClassname());
        Map<String ,Object> retData = new HashMap<>();
        if(userOld != null){
            retData.put("code",500);
            retData.put("message","用户名或密码重复");
        }else {
            userMapper.insertUser(user);
            retData.put("code",200);
            retData.put("message","注册成功!");
        }
        return retData;
    }
}
